<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <list-com></list-com>
      <nav-com ref="navref"></nav-com>
    </div>
    <script src="vue.js"></script>
    <script>
      var vm = new Vue({
        el: '#app',
        data() {
          return {
            msg: '消息'
          }
        },
        methods: {
          say() {
            alert(1)
          }
        },
        components: {
          listCom: {
            template: `<div>；list组件</div>`,
            mounted() {
              //父子的生命周期  子组件的生命周期先触发
              // this.$parent
              this.$parent.say()
            }
          },
          navCom: {
            template: `<div>导航组件</div>`,
            data() {
              return {
                myname: '小李'
              }
            },
            mounted() {}
          }
        },
        mounted() {
          console.log(111)
          // this.$watch()
          // this.$nextTick(() => {})
          // this.$parent
          // this.$children 获取子组件集合
          // console.log(this.$children)
          // this.$refs.名称  获取元素或子组件
          console.log(this.$refs.navref.myname)
        }
      })
      // vue的组件构造器
      // var COM = Vue.extend({
      //   data() {
      //     return {}
      //   }
      // })
      var com = new COM()
      // vm.$el    $data   $watch   $mount()  $nextTick()
    </script>
  </body>
</html>
